﻿namespace SupportSystemUI.Controls.Pages
{
    using System;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Media;
    using System.Windows.Media.Animation;

    /// <summary>
    /// Interaction logic for LoadingPage.xaml
    /// </summary>
    public partial class LoadingPage : UserControl
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="LoadingPage"/> class.
        /// </summary>
        public LoadingPage()
        {
            this.InitializeComponent();

            this.Loaded += (sender, args) =>
            {
                DoubleAnimation animation = new DoubleAnimation
                {
                    From = 0,
                    To = 360,
                    Duration = new Duration(TimeSpan.FromSeconds(1.5)),
                    RepeatBehavior = RepeatBehavior.Forever,
                };

                RotateTransform rotation = new RotateTransform
                {
                    CenterX = this.loopIcon.ActualWidth / 2,
                    CenterY = this.loopIcon.ActualHeight / 2,
                };

                rotation.BeginAnimation(RotateTransform.AngleProperty, animation);
                this.loopIcon.RenderTransform = rotation;
            };
        }
    }
}
